import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

const platform = MethodChannel('samples.chenhang/utils');

class ChanelDemoPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
        child: ElevatedButton(
      onPressed: handleButtonClick,
      child: Text("Invode Native"),
    ));
  }

  handleButtonClick() async {
    int result;
    try {
      result = (await platform.invokeMethod("openAppMarket")) as int;
    } catch (e) {
      print("catch e:"+e.toString());
      result = -1;
    }

    print("Result :$result");
  }
}
